package com.sjg.sys.controller;

import com.sjg.sys.entity.SysPage;
import com.sjg.sys.entity.SysPageCol;
import com.sjg.sys.entity.SysUser;
import com.sjg.sys.service.SysUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by fuqingjian on 2017/4/30.
 */
@Controller
@RequestMapping("user")
public class SysUserController {
    @Resource
    private SysUserService sysUserService;
    @RequestMapping("index")
    public String index(){
        return "user";
    }

    @RequestMapping("queryByUserPage")
    @ResponseBody
    public SysPage queryByUserPage(SysPage<SysUser> page){
        List<SysPageCol> cols=new ArrayList<>();
        SysPageCol col0=new SysPageCol();
        col0.setName("登陆名");
        col0.setField("loginName");
        SysPageCol col1=new SysPageCol();
        col1.setName("姓名");
        col1.setField("name");
        SysPageCol col3=new SysPageCol();
        col3.setName("编号");
        col3.setField("userCode");
        SysPageCol col2=new SysPageCol();
        col2.setName("是否锁定");
        col2.setField("locked");
        col2.setRender("lockRender");
        cols.add(col0);
        cols.add(col1);
        cols.add(col3);
        cols.add(col2);
        page.setCols(cols);

        return sysUserService.selectByUserPage(page);
    }
    @RequestMapping("addUserIndex")
    public String addUserIndex(){
        return "addUser";
    }
}
